import { homeList, getVCode, bindPhone, giftCard, buyCard, exChange, orderList,searchWords,searchGoods,wallet,accountLog,goodsCate,goodsList,giftCardDetail,Address,add2Cart,cartList,updateCartNum,addrDetail,editAddr,buyGift,payCode,AsyncUpdateCart,goodsInfo,recharge,getGoodsListByNavId,myCollect,feedBack,recommand,cancelOrder,confirmOrder,cardPay,cardSubmit,order_detail,annidou,user_sign,wxjsApi,addressConfig,delAddress,goodsListForFVipPrivate,collect_goods,activity_goods,calcPrice,drawGoods,pickCoupon,myCoupon,lastMessage,messageList,messageDetail} from '@/api/data';
export default {
    homeList({ commit }) {
        return new Promise((resolve, reject) => {
            homeList().then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    getSmsCode({ commit }, data) {
        return new Promise((resolve, reject) => {
            getVCode(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    bindPhone({ commit }, data) {
        return new Promise((resolve, reject) => {
            bindPhone(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    giftCard( { commit },data ) {
        return new Promise((resolve, reject) => {
            giftCard(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    giftCardDetail( { commit },data ) {
        return new Promise((resolve, reject) => {
            giftCardDetail(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    buyGift( { commit },data ) {
        return new Promise((resolve, reject) => {
            buyGift(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    exChange( { commit }, data ) {
        return new Promise((resolve, reject) => {
            exChange(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },

    //订单
    orderList( { commit }, data ) {
        return new Promise((resolve, reject) => {
            orderList(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })

        })
    },
    payCode( { commit }, data ) {
        return new Promise((resolve, reject) => {
            payCode(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })

        })
    },

    searchWords( { commit }, data ) {
        return new Promise((resolve, reject) => {
            searchWords(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    searchGoods( { commit }, data ) {
        return new Promise((resolve, reject) => {
            searchGoods(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    wallet( { commit }, data ) {
        return new Promise((resolve, reject) => {
            wallet(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    annidou( { commit }, data ) {
        return new Promise((resolve, reject) => {
            annidou(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    accountLog( { commit }, data ) {
        return new Promise((resolve, reject) => {
            accountLog(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    goodsCate( { commit }, data ) {
        return new Promise((resolve, reject) => {
            goodsCate(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    goodsList( { commit }, data ) {
        return new Promise((resolve, reject) => {
            goodsList(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    Address( { commit } ) {
        return new Promise((resolve, reject) => {
            Address().then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    addrDetail( { commit }, data ) {
        return new Promise((resolve, reject) => {
            addrDetail(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    editAddr( { commit }, data ) {
        return new Promise((resolve, reject) => {
            editAddr(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    add2Cart( { commit }, data ) {
        return new Promise((resolve, reject) => {
            add2Cart({
                goods_id: data.goods_id,
                goods_num: data.goods_num || 1,
                item_id: data.item_id || 0,
            }).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },

    cartList( { commit }, data ) {
        return new Promise((resolve, reject) => {
            cartList(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    updateCartNum( { commit }, data ) {
        return new Promise((resolve, reject) => {
            updateCartNum(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    AsyncUpdateCart( { commit }, data ) {
        return new Promise((resolve, reject) => {
            AsyncUpdateCart(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    goodsInfo( { commit }, data ) {
        return new Promise((resolve, reject) => {
            goodsInfo(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    recharge( { commit }, data ) {
        return new Promise((resolve, reject) => {
            recharge(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    goodsListByNavId( { commit }, data ) {
        return new Promise((resolve, reject) => {
            getGoodsListByNavId(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    myCollect( { commit }, data ) {
        return new Promise((resolve, reject) => {
            myCollect(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    feedBack( { commit }, data ) {
        return new Promise((resolve, reject) => {
            feedBack(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    recommand( { commit }, data ) {
        return new Promise((resolve, reject) => {
            recommand(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    cancelOrder( { commit }, data ) {
        return new Promise((resolve, reject) => {
            cancelOrder(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    confirmOrder( { commit }, data ) {
        return new Promise((resolve, reject) => {
            confirmOrder(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    cardPay( { commit }, data ) {
        return new Promise((resolve, reject) => {
            cardPay(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    cardSubmit( { commit }, data ) {
        return new Promise((resolve, reject) => {
            cardSubmit(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    order_detail( { commit }, data ) {
        return new Promise((resolve, reject) => {
            order_detail(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    user_sign( { commit }, data ) {
        return new Promise((resolve, reject) => {
            user_sign(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    wxjsApi( { commit }, data ) {
        return new Promise((resolve, reject) => {
            wxjsApi(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    addressConfig( { commit }, data ) {
        return new Promise((resolve, reject) => {
            addressConfig(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    delAddress( { commit }, data ) {
        return new Promise((resolve, reject) => {
            delAddress(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    goodsListForFVipPrivate( { commit }, data ) {
        return new Promise((resolve, reject) => {
            goodsListForFVipPrivate(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    collect_goods( { commit }, data ) {
        return new Promise((resolve, reject) => {
            collect_goods(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    activity_goods( { commit }, data ) {
        return new Promise((resolve, reject) => {
            activity_goods(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    calcPrice( { commit }, data ) {
        return new Promise((resolve, reject) => {
            calcPrice(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    drawGoods( { commit }, data ) {
        return new Promise((resolve, reject) => {
            drawGoods(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    pickCoupon( { commit }, data ) {
        return new Promise((resolve, reject) => {
            pickCoupon(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    myCoupon( { commit }, data ) {
        return new Promise((resolve, reject) => {
            myCoupon(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    lastMessage( { commit }, data ) {
        return new Promise((resolve, reject) => {
            lastMessage(data).then(res => {
                // commit('publicMessage', res)
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    messageList( { commit }, data ) {
        return new Promise((resolve, reject) => {
            messageList(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
    messageDetail( { commit }, data ) {
        return new Promise((resolve, reject) => {
            messageDetail(data).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        })
    },
}